package com.itheima.Service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.Service.OrderService;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.mapper.OrderDao;
import com.itheima.pojo.CheckItem;
import com.itheima.pojo.Order;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderDao orderDao;

    @Override
    public PageResult findPage(QueryPageBean page) {
        PageHelper.startPage(page.getCurrentPage(),page.getPageSize());
        List<Order > orders=orderDao.findPage(page);
        Page<Order> orders1=(Page<Order>)orders;
        return new PageResult(orders1.getTotal(),orders);

    }

    @Override
    public void update(Order order) {
        orderDao.update(order);
    }
}
